﻿<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.researchsubject.domain.*" pageEncoding="UTF-8"%>
<%@page import="com.hs.core.page.PageUtil,com.hs.core.utils.*,cn.ac.cintcm.dataconverge.researcher.domain.*"%>
<%@page import="cn.ac.cintcm.dataconverge.util.Constants;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
PageUtil pageUtil = (PageUtil)request.getAttribute("subjectList");
List resultList = null;
String pageStr = ""; 
int perpageCount = 1;
int currentPage = 1;
if(null != pageUtil){
   resultList = pageUtil.getPageList();
   pageStr = pageUtil.getPageStr();
   perpageCount = pageUtil.getNumberPerPage();
   currentPage = pageUtil.getCurrentPage();
}
String subjectname = (String)request.getAttribute("subjectname");
String startdate = (String)request.getAttribute("startdate");
String enddate = (String)request.getAttribute("enddate");
String startyear = (String)request.getAttribute("startyear");
String endyear = (String)request.getAttribute("endyear");
String snumber = (String)request.getAttribute("snumber");
String status = (String)request.getAttribute("status");

String onreserach = (String)request.getAttribute("onreserach");
String onpermit = (String)request.getAttribute("onpermit");
String finishSubject = (String)request.getAttribute("finishSubject");

String orderName = (String)request.getAttribute("orderName");
String orderNum = (String)request.getAttribute("orderNum"); 
String orgId = (String)request.getAttribute("orgId"); 
List orgList = (List)request.getAttribute("orgList");
List dictList = (List)request.getAttribute("dictList");
String subjectUser = (String)request.getAttribute("subjectUser");
 
String studyDict = (String)request.getAttribute("studyDict");

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>课题信息</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link href="<%=path%>/index/Themes/com/style.css" rel="stylesheet" type="text/css" /> 
    <script src="<%=path%>/index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
     <script src="<%=path%>/js/common.js" language="javascript" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript">
        function ChangeSelect()
        {
        var sel = document.getElementById("Select3");
        var sel1 = document.getElementById("Select1");
        var sel2 = document.getElementById("Select2");
        //alert(sel2.value);
            switch(sel.value)
            {
                case "1":
                    xczd.style.display='';
                    
                    break;
                case "":
                    xczd.style.display='none';
                    
            }
            switch(sel1.value)
            {
                case "1":
                    Tr1.style.display='';
                    break;
                case "":
                    Tr1.style.display='none';                    
            }
            switch(sel2.value)
            {
                case "1":
                    Tr2.style.display="";
                    
                  break;
                case "":
                    Tr2.style.display="none";
            }
        }
       function delSubject(id){
       		if(null != id && id != '' ){
       		 	if(confirm("确认删除课题?")){
       		 		form1.action = '<%=path%>/subjectToAdd.htm?action=delSubject&id='+id;
       		 		form1.submit();
       		 	}
       		}
       
       }
       function searchSubject(){ 
       	
       			searchform.submit();			
       }
       function checkedAll(){
       		var isall = document.getElementById("checkAll").value;  
       		var allSubject = document.getElementsByName("subjectId"); 
       		if('1' == isall){ 
       			if(allSubject != null){
       				for(var i = 0;i<allSubject.length;i++){
       					if(!allSubject[i].checked)
       						allSubject[i].checked = true;
       				}
       			
       			} 
       			document.getElementById("checkAll").value = '0'; 
       		}else{
       			if(allSubject != null){
       				for(var i = 0;i<allSubject.length;i++){
       					if(allSubject[i].checked)
       						allSubject[i].checked = false;
       				}
       			
       			} 
       		    document.getElementById("checkAll").value = '1'; 
       		}
       
       }
       function auditSubjects(){
       		var objs = document.getElementsByName("subjectId");
       		var idStr = '';
       		if(null != objs){ 
      				var i = 0;
      				var subjectid = '';
      				for(var k = 0;k<objs.length;k++){
      					if(objs[k].checked){
      						subjectid = objs[k].value;
      						i++;
      						idStr += subjectid+',';
      					}
      				}
      				if(i==0){
      					alert("请至少选择一个课题进行审批");
      					return;
      				}else{
      				 	openwindow('<%=path%>/subjectModify.htm?action=forwardModifyStatus&idStr='+idStr,'800','600','');
      				}  
       		}
       		
       }
    </script>

</head>
<body class="rtm_body" scroll=yes>
<form name="searchform" action = "<%=path%>/subject.htm?action=listWaitAuditSubjects" method="post">
    <div class="r_rtm_tb_mg1">
        <div class="r_rtm_tb1">
            <span>
                <img src="<%=path%>/index/Themes/com/idt_tb_pass.gif" />&nbsp;&nbsp;课题查询</span>
        </div>
    </div>     
     <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
        <tr>
            <td class="fim_l" width="10%">
                课题名称：</td>
            <td class="fim_r" width="25%">
                <input type="text" name="subjectname" value="<%=subjectname==null?"":subjectname %>" class="com_textbox" ></td>
            <!-- td class="fim_l">
                申报日期：</td>
            <td class="fim_r" nowrap width="30%">
                从
               <input type="text" class="Wdate" id="startdate" value="<%=startdate==null?"":startdate %>" style="width:40%" name="startdate"  onFocus="WdatePicker({el:'startdate',dateFmt:'yyyy-MM-dd'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="enddate" value="<%=enddate==null?"":enddate %>" style="width:40%" name="enddate"  onFocus="WdatePicker({el:'enddate',dateFmt:'yyyy-MM-dd'})" />
            </td-->
            <td class="fim_l" width="10%">
                完成单位：</td>
            <td class="fim_r" nowrap width="25%">
               <select name="orgId" style="width:100%">
                <option value=""></option>
                <%
                
                 if(orgList.size()>0){ 
                	 for(int i =0;i<orgList.size();i++){
                		 Organization org = (Organization)orgList.get(i);
                		 out.print("<option value=");
                		 out.print(org.getId());
                		 if((org.getId()+"").equals(orgId))
                		 	out.print(" selected");
                		 out.print(">");
                		 out.print(org.getName());
                		 out.print("</option>");
                	 }
                 }
                %>
                </select>
            </td>
            <td class="fim_l" width="10%">
               重点学科</td>
            <td class="fim_r" width="25%"> 
                  <select name="studyDict" style="width:100%">
                   <option value=""> </option>
                   <%
                     if(null != dictList && dictList.size()>0){
                    	 for(int i =0;i<dictList.size();i++){
                    		 SystemDict dict = (SystemDict)dictList.get(i);
                    		 out.println("<option value=");
                    		 out.println(dict.getId());
                    		 if((dict.getId()+"").equals(studyDict)){
                    			 out.println(" selected");
                    		 }
                    		 out.println(">");
                    		 out.println(dict.getName());
                    		 out.println("<option>");
                    	 }
                     } 
                   %>
                  
                  </select>
            </td>
        </tr>
        <tr>
            <td class="fim_l">
                课题负责人：</td>
            <td class="fim_r">
                <input type="text" name="subjectUser" value="<%=subjectUser==null?"":subjectUser %>" class="com_textbox" id="Text2" name="Text2"></td>
            
            <td class="fim_l">
                课题状态：</td>
            <td class="fim_r" nowrap width="30%">
               <select name="status" style="width:100%">
                 <option value="-1">----请选择----</option>
                 <option value="<%=Constants.subject_state_save%>" <%if((""+Constants.subject_state_save).equals(status)){out.println(" selected");} %>>未提交审批</option>
                 <option value="<%=Constants.subject_state_apply%>" <%if((""+Constants.subject_state_apply).equals(status)){out.println(" selected");} %>>申报中</option>
                  <option value="<%=Constants.subject_state_advised%>" <%if((""+Constants.subject_state_advised).equals(status)){out.println(" selected");} %>>推荐中标</option>
                   <option value="<%=Constants.subject_state_checked%>" <%if((""+Constants.subject_state_checked).equals(status)){out.println(" selected");} %>>中标</option>
                 <option value="<%=Constants.subject_state_researching%>" <%if((""+Constants.subject_state_researching).equals(status)){out.println(" selected");} %>>在研</option>
                 <option value="<%=Constants.subject_state_endApply%>" <%if((""+Constants.subject_state_endApply).equals(status)){out.println(" selected");} %>>申请结题</option>
                
 
                 
                </select>  
            </td>
            <td class="fim_r" align="right" colspan="2">
                <input type="submit" value="查询"  onclick="searchSubject()" class="com_btn2" id="Button5">
                <input type="button" value="高级查询"   onclick="if(AdCheckForm.style.display=='none')AdCheckForm.style.display='';else AdCheckForm.style.display='none';"
                    class="com_btn2" id="Button1">
                 <input type="button" value="修改状态"   class="com_btn2"   onclick="auditSubjects()">
            </td>
        </tr>
        <tr id="AdCheckForm" style="display: none;">
            <td class="fim_l">
                课题编号：</td>
            <td class="fim_r">
                <input type="text" class="com_textbox" id="snumber" value="<%=snumber==null?"":snumber %>" name="snumber"></td>
            <td class="fim_l">
                所属年份：</td>
            <td class="fim_r">
                从
               <input type="text" class="Wdate" id="startyear" value="<%=startyear==null?"":startyear %>" style="width:40%" name="startyear"  onFocus="WdatePicker({el:'startyear',dateFmt:'yyyy'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="endyear" value="<%=endyear==null?"":endyear %>" style="width:40%" name="endyear"  onFocus="WdatePicker({el:'endyear',dateFmt:'yyyy'})" />
            </td>
            <td class="fim_l">
               </td>
            <td class="fim_r"> 
                  
            </td>
        </tr>
        </form>
    </table> 
   
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <div class="content">
                 <form name="form1" action="" method="post">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4">
                        <tr> 
                            <td class="dg_headerstyle" width="5%">
                                <input type="checkbox" value="1" onclick="checkedAll();" id="checkAll"/>全选</td>
                            <td class="dg_headerstyle" width="5%">
                                序号</td>
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('snumber','<%=OrderTool.getOrderNum("snumber",orderName,orderNum)%>');">课题编号&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("snumber",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="20%">
                                <a href="javaScript:orderPage('subjectname','<%=OrderTool.getOrderNum("subjectname",orderName,orderNum)%>');">课题名称&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("subjectname",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('state','<%=OrderTool.getOrderNum("state",orderName,orderNum)%>');">当前状态&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("state",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle">
                                牵头单位</td>
                                 <td class="dg_headerstyle">
                                负责人</td> 
                            <td class="dg_headerstyle">
                                课题来源</td>
                                  <td class="dg_headerstyle" width="6%">
                                 <a href="javaScript:orderPage('startdate','<%=OrderTool.getOrderNum("startdate",orderName,orderNum)%>');">计划开始日期&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("startdate",orderName,orderNum))%></a></td> 
                             
                        </tr>
                        <%if(null != resultList && resultList.size()> 0){
                            for(int i = 0;i < resultList.size();i++){
                                    Subject obj = (Subject)resultList.get(i); 
                         %>
                        <tr class="dg_alternatingitemstyle" onmouseover="ChangeRowBg(this);" onmouseout="ChangeRowBg(this);" onmouseup="ChangeRowBg(this);" onmousedown="ChangeRowBg(this);">
                         <td align="center"><input type="checkbox" value="<%=obj.getId() %>" name="subjectId"/></td>
                            <td align="center"><%= perpageCount*(currentPage-1)+i+1 %></td>
                            <td align="center">
                             <%=StringUtilTool.NULL2Blank(obj.getSnumber()) %>
                            </td>
                            <td>
                                  <a href="#"   onclick="openwindow('<%=path %>/subjectToAdd.htm?action=viewSubject&id=<%=obj.getId() %>','','','')"> <%=StringUtilTool.NULL2Blank(obj.getSubjectname()) %></a>
                            </td>
                            <td align="center">
                                <font color="red"><%=Constants.getSubjectStatus(obj.getState()) %></font>
                            </td>
                            <td width="30%">
                                <%
                                   if(obj != null){
                                     Set orgs = obj.getSubOrg();
                                     Iterator it = orgs.iterator();
                                     int h = 0;
                                     while(it.hasNext()){
                                    	 
                                         SubOrg org = (SubOrg)it.next();
                                         if(Constants.org_role_leader.equals(org.getOrgRole()+"")){
                                        	 h++;
                                        	 out.println(org.getOrg()==null?"":org.getOrg().getName()+"&nbsp;"); 
                                         }
                                        // if(h>1)
                                        //	 out.println(",");
                                     }
                                   } 
                                 %>
                            </td>
                            <td  width="6%">
                                 <%
                                   if(obj != null){
                                     Set res = obj.getSubRes();
                                     Iterator it = res.iterator();
                                     int j = 0;
                                     while(it.hasNext()){
                                    	
                                         SubRes rearcher = (SubRes)it.next();
                                         if(Constants.researcher_role_chargeman.equals(rearcher.getResRole()+"")){
                                        	 j++;
                                        	 out.println(rearcher.getRes()==null?"":rearcher.getRes().getName()+"&nbsp;"); 
                                         }
                                        // if(j>1)
                                        //	 out.println(",");
                                     }
                                   } 
                                 %>
                            </td>
                            <td>
                                 <%
                                   if(obj != null){
                                     Set tags = obj.getTags();
                                     Iterator ittag = tags.iterator();
                                     while(ittag.hasNext()){
                                    	 SubTag tag = (SubTag)ittag.next();
                                         if(null != tag && tag.getTag() != null && tag.getTag().getTagType() == 1)
                                         	out.println( tag.getTag().getName());
                                     }
                                   } 
                                 %>
                            </td>
                            <td  width="6%">
                                <%=Tools.getDateStringByDate1(obj.getStartdate()) %>
                            </td> 
                        </tr> 
                        <%}}else{%>
                         <tr class="dg_alternatingitemstyle"> 
                            <td align="center" colspan=11>
                                <font color="red">没有找到记录</font>
                            </td> 
                        </tr> 
                        <%}%>
                    </table>
                    </form>
                    <div class="dg_pagerstyle" align="right"> 
                            <%=pageStr %>  
                    </div> 
                </div>
            </td>
        </tr>
    </table>
</body>
</html>
